<template>
   <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>课程管理</el-breadcrumb-item>
      <el-breadcrumb-item>学生选课</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片 -->
    <el-card class="box-card"> 
        <!-- 表格 -->
        <el-table :data="choiceclassdata.classlist">
            <el-table-column type="index"></el-table-column>
            <el-table-column label="课程序号" prop="classId"></el-table-column>
            <el-table-column label="课程名称" prop="className"></el-table-column>
            <el-table-column label="教室" prop="classPlace"></el-table-column>
            <el-table-column label="教师" prop="classTeacher"></el-table-column>
            <el-table-column label="专业" prop="classMaior"></el-table-column>
            <el-table-column label="学分" prop="classCredit"></el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                  <el-button @click="choiceclass(scope.row)">选课</el-button>
              </template>
            </el-table-column>
        </el-table>
    </el-card>
  </div>
</template>

<script>
import axios from 'axios'
import qs from "qs";
export default {
   data(){
        return{
            choiceclassdata:{
              classlist:[],
              psw:this.$route.params.password,
            },

            page:1
        }
    },
  created() {
     axios
        .post("http://localhost:3000/getclasslist", {
          page: this.page,
        })
        .then((res) => {
          this.choiceclassdata.classlist = res.data;
        });
  },
  methods:{
    choiceclass(row){
      console.log(row);
      axios.post('http://localhost:3000/choice',{data:row,flot:this.choiceclassdata.psw}).then((res)=>{
        console.log(res);
      })
    }
  }
}
</script>

<style>

</style>